package com.heaven.exception;

import com.heaven.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLIntegrityConstraintViolationException;

@RestControllerAdvice
public class RegisterExceptionHandler {

    @ExceptionHandler(SQLIntegrityConstraintViolationException.class)
    public Result ex(Exception ex){
        ex.printStackTrace();
        return Result.error("用户名已存在");
    }
}
